//
//  ImageCheckVC.m
//  Repair_iOS
//
//  Created by ZhangPeng on 2017/11/13.
//  Copyright © 2017年 张朋. All rights reserved.
//

#import "ImageCheckVC.h"

@interface ImageCheckVC ()

@property (strong, nonatomic) UIImageView *imageView;
@property (strong, nonatomic) UIImage *image;
@property (strong, nonatomic) NSString *urlString;

@property (weak, nonatomic) IBOutlet UIScrollView *scorllView;
@property (strong, nonatomic) NSArray *imagesArr;
@property (assign, nonatomic) NSInteger index;

@end

@implementation ImageCheckVC

- (instancetype)initWithImage:(UIImage *)image
{
    self = [super init];
    if (self) {
        self.image = image;
    }
    return self;
}

- (instancetype)initWithURLString:(NSString *)urlstring
{
    self = [super init];
    if (self) {
        self.urlString = urlstring;
    }
    return self;
}

- (instancetype)initWithImgsArr:(NSArray *)imgsArr andIndex:(NSInteger)index
{
    self = [super init];
    if (self) {
        self.imagesArr = imgsArr;
        self.index = index;
    }
    return self;
}

- (IBAction)closeAction:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.scorllView.contentSize = CGSizeMake(kScreenWidth * self.imagesArr.count, self.scorllView.height);
    
    for (int i = 0; i < self.imagesArr.count; i++) {
        NSString *urlString = [self.imagesArr objectAtIndex:i];
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i * kScreenWidth, 0, kScreenWidth, self.scorllView.height)];
        [imageView sd_setImageWithURL:[NSURL URLWithString:urlString]];
        imageView.contentMode = UIViewContentModeScaleAspectFit;
        [self.scorllView addSubview:imageView];
        imageView.backgroundColor = [UIColor blackColor];
    }
    
    [self.scorllView setContentOffset:CGPointMake(self.index * kScreenWidth, self.scorllView.height)];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
